package crushbum;

import com.funkyfurrymonkey.load.AssetsRepository;
import com.funkyfurrymonkey.load.Preloader;
import com.funkyfurrymonkey.load.XMLLoader;
import crushbum.gamelevels.GameLevel;
import openfl.display.Loader;
import openfl.display.Sprite;

/**
 * ...
 * @author Marcos Martinez
 */
class CrushBum extends Sprite
{

	private var m_cDataController:DataController;
	var cPreloader:Preloader;
	public function new() 
	{
		super();
		m_cDataController = new DataController();
		m_cDataController.m_cMainCanvas = this;
	}
	
	public function init() 
	{		
		 cPreloader = new Preloader(this,m_cDataController.m_cAssetsRepo );
		cPreloader.onComplete = preloadComplete;
		cPreloader.start("assets/main.xml");
	}
	
	private function preloadComplete()
	{
		trace("preload complete");
		var cScreen = new GameLevel(m_cDataController);
		cScreen.create(1);
		cScreen.ready = levelCreated;
	}
	
	function levelCreated() 
	{
		cPreloader.removePreloaderScreen();
		
	}
}